package pl.edu.agh.iosr.gamblingzone.model;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import javax.persistence.AttributeOverride;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;

@AttributeOverride(name="id",
		column=@Column(name="AEVENT_ID"))
@Entity
@Inheritance(strategy = InheritanceType.JOINED)
public class AbstractEvent extends IEntity {

	@Column(name="AEVENT_CLOSING_DATE", nullable=false)
	private Date closingDate;
	
	@Column(name="AEVENT_CREATION_DATE", nullable=false)
	private Date creationDate = new Date();
	
	@OneToOne
	@JoinColumn(name="AEVENT_WINNER")
	private Participant winner;
	
	@OneToMany
	private Map<Double, Participant> rates = new HashMap<Double, Participant>();
	
	@ManyToOne
	@JoinColumn(name="GROUP_ID", nullable=false)
	private Group group;

	public Map<Double, Participant> getRates() {
		return rates;
	}

	public void setRates(Map<Double, Participant> rates) {
		this.rates = rates;
	}

	public Group getGroup() {
		return group;
	}

	public void setGroup(Group group) {
		this.group = group;
	}

	public Participant getWinner() {
		return winner;
	}

	public void setWinner(Participant winner) {
		this.winner = winner;
	}

	public Date getClosingDate() {
		return closingDate;
	}

	public void setClosingDate(Date closingDate) {
		this.closingDate = closingDate;
	}

	public Date getCreationDate() {
		return creationDate;
	}

	public void setCreationDate(Date creationDate) {
		this.creationDate = creationDate;
	}
}
